package com.mnb.base.controller;

import com.mnb.base.entity.StZqrlB;
import com.mnb.base.entity.StZqrlB;
import com.mnb.base.service.StZqrlBService;
import com.mnb.base.service.impl.StZqrlBServiceImpl;
import com.mnb.common.utils.R;
import org.apache.ibatis.annotations.Param;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * (ST_ZQRL_B)表控制层
 *
 * @author xxxxx
 */
@RestController
@RequestMapping("/st_zqrl_b")
public class StZqrlBController {
    /**
     * 服务对象
     */
    @Resource
    private StZqrlBService stZqrlBService;

    @RequestMapping("/getList")
    public R getList(StZqrlB stZqrlB){
        return stZqrlBService.getList(stZqrlB);
    }

    @RequestMapping("/getLineList")
    public R getLineList(StZqrlB stZqrlB){
        return stZqrlBService.getLineList(stZqrlB);
    }

    @RequestMapping("/list")
    public R list(StZqrlB stZqrlB) {
        return stZqrlBService.getList(stZqrlB);
    }

    @RequestMapping("/insert")
    public R insert(@RequestBody StZqrlB stZqrlB) {
        stZqrlB.setModitime(new Date());
        return stZqrlBService.insert(stZqrlB);
    }

    @RequestMapping("/udpate")
    public R udpate(@RequestBody StZqrlB stZqrlB) {
        return stZqrlBService.udpate(stZqrlB);
    }

    @RequestMapping("/delete")
    @Transactional
    public R delete(@RequestBody List<StZqrlB> list) {
        for (StZqrlB stZqrlB : list) {
            stZqrlBService.deleteByPrimaryKey(stZqrlB.getStcd(), stZqrlB.getLnnm(), stZqrlB.getBgtm(),stZqrlB.getPtno());
        }
        return R.ok();
    }

    @RequestMapping("/getLastBgtmList")
    public R getLastBgtmList(StZqrlB stZqrlB) {
        return stZqrlBService.getLastBgtmList(stZqrlB);
    }


}
